<?php
class ringtoneLib
{
	static public function sendSmsDownload($toPhone, $fileName)
	{	
		$fileName = iringback::strKhongDau($fileName);
		
		if (sfConfig::get('enable_send_sms'))
		{	
			sfContext::getInstance()->getLogger()->err('sendSMS:'.$toPhone.':'.$fileName);
			
			$smsDesc = sprintf(sfConfig::get('sms_upload_convert_song'), $fileName);
								
			$smsClient = new smsClient();
			
			$ret = $smsClient->sentMT(
	                            '9282',
								$toPhone,
								sfConfig::get('sms_text_type'),
								$smsDesc,
								1,
								'',
								'0',
								$toPhone
								);
								
			//var_dump($ret);
			//sfContext::getInstance()->getLogger()->err("ret = tien ");
		}
	}
	static public function resendSmsDownload($type, $ringtoneId, $toPhone, $senderPhone, $price)
	{
			sfContext::getInstance()->getLogger()->err("ringtoneLib::sendSmsDownload = ".sfConfig::get('enable_send_sms'));
            if (sfConfig::get('enable_send_sms'))
            {   $url = sms::createWapUrl($ringtoneId, $price, $type);
            	if ($type == 1)	//download
                {                    
                    $smsDesc = sfConfig::get('sms_rt_download');
                }else if ($type == 2) //send sms
                {                    
                    $smsDesc = sprintf(sfConfig::get('sms_rt_share_receiver'), $senderPhone);
                }
				$smsClient = new smsClient();
                $ret = $smsClient->sentMT('9282',
                                            $toPhone,
                                            sfConfig::get('sms_wappush_type'),
                                            $url,
                                            0,
                                            $smsDesc,
                                            '0',
                                            $senderPhone
                                            );
                $textTypeRet = $smsClient->sentMT('9282',
                                            $toPhone,
                                            sfConfig::get('sms_text_type'),
                                            $url,
                                            0,
                                            $smsDesc,
                                            '0',
                                            $senderPhone
                                            );
               $result = explode('|',$ret->return);
               return $result;
            }
	}
	
    static public function sendSms($toPhone,$content)
	{
            sfContext::getInstance()->getLogger()->err("ringtoneLib::sendSms = ".sfConfig::get('enable_send_sms'));
            if (sfConfig::get('enable_send_sms'))
            { 
                $smsClient = new smsClient();
                $ret = $smsClient->sentMT('9282',
                                            $toPhone,
                                            0,
                                            $content,
                                            0,
                                            $content,
                                            '0',
                                            $toPhone
                                            );
                $result = explode('|',$ret->return);
                return $result;
            }
	}
}
?>